import { createRouter, createWebHistory } from "vue-router";
import Index from "../views/Index.vue";
import MainFrame from "../views/MainFrame.vue";
import Login from "../views/Login.vue";
import Home from "../views/Home.vue";
import User from "../views/User.vue";
import Mall from "../views/Mall.vue";
import PageOne from "../views/PageOne.vue";
import PageTwo from "../views/PageTwo.vue";
import Register from "../views/Register.vue";

const routes = [
  // {
  //   path: "/index",
  //   component: Index,
  // },
  // {
  //   path: "/",
  //   redirect: "/index",
  // },
  // {
  //   path: "/login",
  //   // component: Login,
  //   component: () => import('@/views/Login'),
  // },
  // {
  //   path: "/register",
  //   component: Register,
  // }
  {
    path: "/",
    name: "Login",
    // component: Login,
    component: () => import('@/views/Login'),

  }, {
    path: "/main",
    name: "Main",
    component: MainFrame,
    // redirect: '/home', // 重定向
    children: [
      // 子路由
      { path: '/home', name: 'home', component: Home }, // 首页
      { path: '/user', name: 'user', component: User }, // 用户管理
      { path: '/mall', name: 'mall', component: Mall }, // 商品管理
      { path: '/page1', name: 'page1', component: PageOne }, // 页面1
      { path: '/page2', name: 'page2', component: PageTwo }, // 页面2

    ]

  }, {
    path: "/login",
    name: "Login",
    component: Login,
  }
]

const router = createRouter(
  {
    routes,
    history: createWebHistory(),
  })

export default router